<?php
/**
 * Created by PhpStorm.
 * User: Antique
 * Date: 2021/12/15
 * Time: 上午 12:40
 */

include_once '../tools/DbTools.php';

$take_Card = $_POST['take_Card'];
$give_money = $_POST['give_money'];
session_start();
$Token = $_COOKIE['Token'];
$username = $_SESSION[$Token]['uesrname'];
$sql_minus = "update bankcard set CardMoney=CardMoney-" . $give_money . " where CardNo='" . $username . "'";
DbTools::InitDb();
$result = DbTools::noSelect($sql_minus);
$flag = $result['status'];
if ($flag) {
    $sql_add = "update bankcard set CardMoney=CardMoney+" . $give_money . " where CardNo='" . $take_Card . "'";
    $result2 = DbTools::noSelect($sql_add);
    $flag2 = $result2['status'];
    if (!$flag2) {
        $message = $result2['message'];
    }
} else {
    $flag2 = false;
    $message = $result['message'];
}
?>

<!DOCTYPE html>
<html>
<script type="text/javascript">
    if (<?php echo $flag2 ?>) {
        alert('转账成功！');
        location.href = '../user/userinfo.php';
    } else {
        alert('转账失败,因为:<?php echo $message ?>');
        location.href = '../user/userinfo.php';
    }
</script>
</html>







